package fstvis;

/**
 * This is more of a structure than anything...
 * This hold stats for two fields
 * 
 * @author matt
 *
 */
public abstract class Stats {
	protected static final double NULL_DOUBLE = 0.1234567; 
	protected double r = NULL_DOUBLE, r2 = NULL_DOUBLE;
	protected double mse = NULL_DOUBLE, rmse = NULL_DOUBLE;
	protected double mne = NULL_DOUBLE;
	protected double mnb = NULL_DOUBLE;
	protected double mfe = NULL_DOUBLE;
	protected double mfb = NULL_DOUBLE;
	protected double min = NULL_DOUBLE, max = NULL_DOUBLE;
	
	public double getR() {
		return r;
	}

	public double getMin() {
		return min;
	}

	public void setMin(double min) {
		this.min = min;
	}

	public double getMax() {
		return max;
	}

	public void setMax(double max) {
		this.max = max;
	}

	public double getR2() {
		return r2;
	}

	public Stats() {
		r = 0; r2 = 0;
		mse = 0; rmse = 0;
		mne = 0; mnb = 0;
		mfe = 0; mfb = 0;
		min = 0; max = 1;
	}

	public void setR(double r) {
		this.r = r;
		this.r2 = Math.pow(r, 2);
	}
	
	public void setMSE(double mse) {
		this.mse=mse;
		this.rmse = Math.sqrt(this.mse);
	}

	public double getMSE() {
		return this.mse;
	}

	public double getMNE() {
		return mne;
	}

	protected void setMNE(double mne) {
		this.mne = mne;
	}

	public double getMNB() {
		return mnb;
	}

	protected void setMNB(double mnb) {
		this.mnb = mnb;
	}

	public double getMFE() {
		return mfe;
	}

	protected void setMFE(double mfe) {
		this.mfe = mfe;
	}

	public double getMFB() {
		return mfb;
	}

	protected void setMFB(double mfb) {
		this.mfb = mfb;
	}

	public String toString() {
		String str = new String();

		if (this.getR()    != Stats.NULL_DOUBLE) str += String.format("r     = %8.5f\n", this.getR());
		if (this.getR2()   != Stats.NULL_DOUBLE) str += String.format("r^2   = %8.5f\n", this.getR2());
		if (this.getMSE()  != Stats.NULL_DOUBLE) str += String.format("MSE   = %8.5f\n", this.getMSE());
		if (this.getRMSE() != Stats.NULL_DOUBLE) str += String.format("RMSE  = %8.5f\n", this.getRMSE());
		if (this.getMNE()  != Stats.NULL_DOUBLE) str += String.format("MNE   = %8.5f\n", this.getMNE());
		if (this.getMNB()  != Stats.NULL_DOUBLE) str += String.format("MNB   = %8.5f\n", this.getMNB());
		if (this.getMFE()  != Stats.NULL_DOUBLE) str += String.format("MFE   = %8.5f%%\n", this.getMFE()*100.0);
		if (this.getMFB()  != Stats.NULL_DOUBLE) str += String.format("MFB   = %8.5f%%\n", this.getMFB()*100.0);
		if (this.getMin()  != Stats.NULL_DOUBLE) str += String.format("Min   = %8.5f\n", this.getMin());
		if (this.getMax()  != Stats.NULL_DOUBLE) str += String.format("Max   = %8.5f\n", this.getMax());

		return str;
	}

	public double getRMSE() {
		return rmse;
	}
}
